/*
 * Powered By XY
 * Since 2020
 */

package com.xy.biz.fd.manager.impl;

import java.util.Collection;
import java.util.List;

import com.xy.biz.fd.dao.DocumentDao;
import com.xy.biz.fd.domain.po.DocumentSharePO;
import com.xy.tool.context.UserContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//import com.xy.biz.fd.domain.po.DocumentPO;

import com.xy.biz.fd.domain.bo.DocumentShareBO;
import com.xy.biz.fd.domain.query.DocumentShareQuery;
import com.xy.biz.fd.domain.converter.DocumentShareConverter;
import com.xy.biz.fd.manager.DocumentShareManager;
import com.xy.biz.fd.dao.DocumentShareDao;

/**
 *
 *
 * @author wcs
 * @date 2021-2-8
 */
@Service
public class DocumentShareManagerImpl implements DocumentShareManager {

	@Autowired
	private DocumentShareDao documentShareDao;

	@Override
	public int saveDocumentShare(DocumentShareBO documentShareBO) {
		return documentShareDao.saveDocumentShare(DocumentShareConverter.toPO(documentShareBO));
	}

	@Override
	public int saveAllDocumentShare(Collection<DocumentShareBO> collection) {
		return documentShareDao.saveAllDocumentShare(DocumentShareConverter.toPO(collection));
	}

	@Override
	public int updateDocumentShare(DocumentShareBO documentShareBO) {
		return documentShareDao.updateDocumentShare(DocumentShareConverter.toPO(documentShareBO));
	}

	@Override
	public int deleteDocumentShare(Long documentShareId) {
		return documentShareDao.deleteDocumentShare(documentShareId);
	}

	@Override
	public int relDeleteDocumentShare(Long documentShareId) {
		return documentShareDao.relDeleteDocumentShare(documentShareId);
	}

	/**
	 * 批量删除
	 *
	 * @param collection
	 */
	@Override
	public int updateDocumentShareS(Collection<Long> collection) {
		return documentShareDao.updateDocumentShareS(collection);
	}

	@Override
	public int deleteDocumentShareS(Collection<Long> documentShareIdS) {
		return documentShareDao.updateDocumentExitsShareS(documentShareIdS);
	}

	@Override
	public DocumentShareBO getDocumentShare(Long documentShareId) {
		DocumentSharePO documentShare = documentShareDao.getDocumentShare(documentShareId);
//		if (documentShare != null){
//			DocumentPO document = documentDao.getDocument(documentShare.getDocumentId());
//		}
		return DocumentShareConverter.fromPO(documentShare);
	}

	@Override
	public List<DocumentShareBO> listDocumentShareById(Collection<Long> collection) {
		return DocumentShareConverter.fromPO(documentShareDao.listDocumentShareById(collection));
	}

	@Override
	public List<DocumentShareBO> listDocumentShare(DocumentShareQuery query) {
		return DocumentShareConverter.fromPO(documentShareDao.listDocumentShare(query));
	}

	@Override
	public int countDocumentShare(DocumentShareQuery query) {
		return documentShareDao.countDocumentShare(query);
	}

	@Override
	public DocumentShareBO getDocumentShareOne(DocumentShareBO documentShareBO) {
		return DocumentShareConverter.fromPO(documentShareDao.getDocumentShareOne(documentShareBO));
	}

	@Override
	public int cancelExistingShare(DocumentShareQuery query) {
		return documentShareDao.cancelExistingShare(query);
	}

}
